<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Users extends CI_Controller {

	public function __construct()
	{
		parent::__construct();

		if(!in_array($this->router->method, array('login','logout','login_error')))
		{
			$this->user_auth->manage();
		}
	}

	public function index()
	{
		//$data = array(
		//	'content' => $this->flat_app->get('index.php')
		//);
		//$this->load->view('template', $data);

		$include_view = $this->menu_lib->get(3);

		$this->load->model('user_model');
		$data = array(
			'users' => $this->user_model->get()->result()
		);
		$include_view .= $this->load->view('users', $data, TRUE);

		$this->load->view('template', array('content' => $include_view));
	}

	public function login()
	{
		$include_view = $this->load->view('form_login', NULL, TRUE);
		$this->load->view('template', array('content' => $include_view));
	}

	public function login_error()
	{
		$include_view = $this->load->view('login_error', NULL, TRUE);
		$this->load->view('template', array('content' => $include_view));
	}

	public function logout()
	{
		$this->session->unset_userdata(array('user' => '', 'passwd' => ''));
		redirect('home/index','refresh');
	}

}

/* End of file users.php */
/* Location: ./application/controllers/users.php */
